package acm.蓝桥24;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 记录每件物品未打折时的最小价格。 找出所有的打折日期，以及打折的物品。 枚举打折的日期，计算该日期购买打折物品的最小值
 */
public class B_打折 {
	static int maxn = 100010;
	static long[] low = new long[maxn]; // 商品未打折的最低价
	static Map<Integer, Map<Integer, Integer>> map = new HashMap<>(); // 每个时间点对应的打折商品以及对应价格
	static int n, m;

	public static void main(String[] args) {
		Reader2 sc = new Reader2();
		n = sc.nextInt();
		m = sc.nextInt();
		Arrays.fill(low, Integer.MAX_VALUE);
		for (int i = 0; i < m; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int p = sc.nextInt();
			int c = sc.nextInt();
			Map<Integer, Integer> left = map.computeIfAbsent(s, (k) -> new HashMap());
			Map<Integer, Integer> right = map.computeIfAbsent(t, (k) -> new HashMap());
			for (int j = 0; j < c; j++) {
				int id = sc.nextInt();
				int price = sc.nextInt();
				int price2 = price * p / 100;
				low[id] = Math.min(low[id], price);
				Integer old = left.get(id);
				if (old == null || old > price2) {
					left.put(id, price2);
				}
				old = right.get(id);
				if (old == null || old > price2) {
					right.put(id, price2);
				}
			}
		}
		long res = compute();
		System.out.println(res);
	}

	static long res;
	static long sum;
	static long cur;
	
	public static long compute() {
		sum = Arrays.stream(low, 1, n + 1).sum();
		res = sum;
		for (Map<Integer, Integer> goods : map.values()) {
			cur = sum;
			goods.forEach((id, val) -> {
				if (low[id] > val) {
					cur -= low[id] - val;
				}
			});
			res = Math.min(res, cur);
		}
		return res;
	}
	
	static class Reader2 {
	    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	    static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    public Reader2(Object... o) {
	    }

	    public int nextInt() {
	        try {
	            in.nextToken();
	        } catch (Exception ignored) {}
	        return (int) in.nval;
	    }
	}
}
